


//
//  NFeedbackPopView.m
//  nncloud
//
//  Created by macfai on 2018/9/27.
//  Copyright © 2018年 youedata. All rights reserved.
//

#import "NFeedbackPopView.h"

@implementation NFeedbackPopView

-(void)layoutSubviews{
    
    [super layoutSubviews];
     self.frame = CGRectMake(0, ScreenHeight-kpopViewHeight-64, ScreenWidth, kpopViewHeight);
    YYLog(@"%f,%d,%d",ScreenHeight,kNavHeight,kpopViewHeight);
    YYLog(@"%f",ScreenHeight);
    
}

-(void)awakeFromNib{
    
    [super awakeFromNib];

    self.backgroundColor = kBackgroundColor;
//    self.backgroundColor = kPinkColor;
    self.textView.placeholder = @"请输入反馈内容";
    self.commitBtn.layer.cornerRadius = 10.f;
    self.commitBtn.layer.masksToBounds = YES;
    
    self.cancelBtn.layer.cornerRadius = 10.f;
    self.cancelBtn.layer.masksToBounds = YES;
    self.cancelBtn.layer.borderWidth = 0.5;
    self.cancelBtn.layer.borderColor = [UIColor darkGrayColor].CGColor;
    
    UIView *topLine = [UIView new];
    topLine.backgroundColor = kDarkGrayColor;
    topLine.frame = CGRectMake(0, 60-5, ScreenWidth, 0.5);
    [self addSubview:topLine];
    
    UIView *bottomLine = [UIView new];
    bottomLine.backgroundColor = kDarkGrayColor;
    bottomLine.frame = CGRectMake(0, 206-5, ScreenWidth, 0.5);
    [self addSubview:bottomLine];
    
}

///方法暂时不用，用视图加载子视图方法添加
-(void)show{
    
    [[UIApplication sharedApplication].keyWindow addSubview:self];
    
//    [UIView animateWithDuration:.3 animations:^{
//        if (ScreenWidth>320) {
//            self.transform = CGAffineTransformMakeTranslation(0,  -kpopViewHeight);
//        }else{
//            self.transform = CGAffineTransformMakeTranslation(0, -240);
//        }
//        
//    }];
}

-(void)setPopBlock:(PopViewBlock)popBlock{
    _popBlock = popBlock;
}

- (IBAction)commitAction:(UIButton *)sender {
    [SVProgressHUD show];
    self.popBlock(self.textView.text);
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self dismiss];
        
        [SVProgressHUD dismiss];
    });
}

- (IBAction)cancelAction:(UIButton *)sender {
    
    [self dismiss];
    
}

-(void)dismiss{
    
    [UIView animateWithDuration:0.3 animations:^{
        
        self.transform = CGAffineTransformIdentity;
        
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
    
}


/*
 /////弹窗用法
 
 //NFeedbackPopView *po = [[[NSBundle mainBundle]loadNibNamed:@"NFeedbackPopView" owner:self options:nil]lastObject];
 //po.popBlock = ^(NSString *text) {
 //    YYLog(@"%@",text);
 //};
 //[self.view addSubview:po];
*/

@end
